procfs
This crate is an interface to the proc
pseudo-filesystem on linux, which is normally mounted as /proc
.
Long-term, this crate aims to be fairly feature complete, but at the moment not all files are exposed.
See the docs for info on what's supported, or view the support.md
file in the code repository.
Examples
There are several examples in the docs and in the examples folder of the code repository.
Here's a small example that prints out all processes that are running on the same tty as the calling process. This is very similar to what "ps" does in its default mode:
Here's another example that shows how to get the current memory usage of the current process:
use Process;
There are a few ways to get this data, so also checkout the longer self_memory example for more details.
Cargo features
The following cargo features are available:
chrono
-- Default. Optional. This feature enables a few methods that return values asDateTime
objects.flate2
-- Default. Optional. This feature enables parsing gzip compressed/proc/config.gz
file via theprocfs::kernel_config
method.backtrace
-- Optional. This feature lets you get a stack trace whenever anInternalError
is raised.serde1
-- Optional. This feature allows most structs to be serialized and deserialized using serde 1.0. Note, this feature requires a version of rust newer than 1.48.0 (which is the MSRV for procfs). The exact version required is not specified here, since serde does not not have an MSRV policy.
Minimum Rust Version
This crate requires a minimum rust version of 1.48.0 (2020-11-19).
License
The procfs library is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
For additional copyright information regarding documentation, please also see the COPYRIGHT.txt file.
Contribution
Contributions are welcome, especially in the areas of documentation and testing on older kernels.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.